<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight_ocaml.ml</title>
<meta name="generator" content="KF5::SyntaxHighlighting (Objective Caml)"/>
</head><body style="color:#1f1c1b"><pre>
<span style="color:#898887;">(* ocaml test file -- a big stew of Objective Caml syntax to use to</span>
<span style="color:#898887;">   test Kate's syntax highlighting. This will not run! :-) *)</span>

<span style="color:#898887;">(* First a little piece of real OCaml that should look right: *)</span>

    <span style="color:#006e28;">#load &quot;basic&quot;;;</span>
    <span style="color:#898887;">(* Return a default value for a BASIC variable given its identifer. *)</span>
    <span style="font-weight:bold;">let</span> default_value (ident : <span style="color:#0057ae;">string</span>) : basic_value =
       <span style="font-weight:bold;">assert</span> (<span style="color:#0057ae;font-style:italic;">String</span>.length ident &gt; <span style="color:#b08000;">0</span>);
       <span style="font-weight:bold;">match</span> ident.[<span style="color:#0057ae;font-style:italic;">String</span>.length ident - <span style="color:#b08000;">1</span>] <span style="font-weight:bold;">with</span>
       | <span style="color:#924c9d;">'$'</span> -&gt; <span style="font-style:italic;">Str</span> <span style="color:#bf0303;">&quot;&quot;</span>
       | <span style="color:#924c9d;">'%'</span> -&gt; <span style="font-style:italic;">Int</span> <span style="color:#b08000;">0</span>
       | <span style="color:#924c9d;">'!'</span> -&gt; <span style="font-style:italic;">Flt</span> <span style="color:#b08000;">0.0</span>
       | _   -&gt; <span style="font-style:italic;">Flt</span> <span style="color:#b08000;">0.0</span>
    ;;

<span style="color:#898887;">(* Directives: *)</span>
<span style="color:#006e28;">#load &quot;pa_o&quot;;;</span>
  <span style="color:#006e28;">#load &quot;pa_o&quot;;;</span>
<span style="font-weight:bold;">object</span> # meth ;;  <span style="color:#898887;">(* not a directive - a method call *)</span>
<span style="font-weight:bold;">object</span>
   # meth ;;  <span style="color:#898887;">(* not a directive - a method call *)</span>

<span style="color:#898887;">(* OCaml keywords: *)</span>
<span style="font-weight:bold;">and</span> <span style="font-weight:bold;">as</span> <span style="font-weight:bold;">assert</span> <span style="font-weight:bold;">asr</span> <span style="color:#898887;">(* etc. there so many... *)</span>

<span style="color:#898887;">(* Additional OCaml Revised Syntax keywords: *)</span>
<span style="color:#898887;">(* These are in a seperate category so they can be coloured to look</span>
<span style="color:#898887;">   like identifiers when ordinary OCaml syntax is being used: *)</span>
declare where value

<span style="color:#898887;">(* There's no way to reliably highlight all OCaml type expressions,</span>
<span style="color:#898887;">   (they can be very complex) so just the built-in type names are highlighted.*)</span>
<span style="color:#0057ae;">exn</span> <span style="color:#0057ae;">lazy_t</span> format <span style="color:#0057ae;">unit</span> <span style="color:#0057ae;">int</span> <span style="color:#0057ae;">real</span> <span style="color:#0057ae;">char</span> <span style="color:#0057ae;">string</span> <span style="color:#0057ae;">ref</span> <span style="color:#0057ae;">array</span> <span style="color:#0057ae;">bool</span> <span style="color:#0057ae;">list</span> <span style="color:#0057ae;">option</span>


<span style="font-weight:bold;">let</span> integers : <span style="color:#0057ae;">int</span> <span style="color:#0057ae;">list</span> = [
    <span style="color:#b08000;">123456789</span>;              <span style="color:#898887;">(* decimal *)</span>
    <span style="color:#b08000;">-0xabcedf0123456789</span>;    <span style="color:#898887;">(* hexadecimal *)</span>
    <span style="color:#b08000;">0xABCDEF0123456789</span>;     <span style="color:#898887;">(* hexadecimal *)</span>
    <span style="color:#b08000;">-0o1234567</span>;             <span style="color:#898887;">(* octal *)</span>
    <span style="color:#b08000;">0b01001010101010</span>;       <span style="color:#898887;">(* binary *)</span>
    <span style="color:#b08000;">-0Xabcedf0123456789</span>;    <span style="color:#898887;">(* hexadecimal *)</span>
    <span style="color:#b08000;">0XABCDEF0123456789</span>;     <span style="color:#898887;">(* hexadecimal *)</span>
    <span style="color:#b08000;">-0O1234567</span>;             <span style="color:#898887;">(* octal *)</span>
    <span style="color:#b08000;">0B01001010101010</span>;       <span style="color:#898887;">(* binary *)</span>
    <span style="color:#b08000;">-123_456_789</span>;           <span style="color:#898887;">(* Underscores are allowed in numeric constants. *)</span>
    <span style="color:#b08000;">0x_abce_df01_2345_6789</span>;
    <span style="color:#b08000;">-0o12_34_567</span>;
    <span style="color:#b08000;">0b_0100_1010_1010_1101</span>;
];;

<span style="font-weight:bold;">let</span> floats : <span style="color:#0057ae;">real</span> <span style="color:#0057ae;">list</span> = [
    <span style="color:#b08000;">12345.6789</span>;
    <span style="color:#b08000;">-1.23456789e4</span>;      <span style="color:#898887;">(* All variations of the exponent form *)</span>
    <span style="color:#b08000;">1.23456789e+4</span>;
    <span style="color:#b08000;">-1.23456789e-4</span>;
    <span style="color:#b08000;">1.23456789E-4</span>;
    <span style="color:#b08000;">-1.23456789E+4</span>;
    <span style="color:#b08000;">12_345.6789</span>;       <span style="color:#898887;">(* Underscores are allowed in numeric constants. *)</span>
    <span style="color:#b08000;">-1.23_456_789e+4</span>;
    <span style="color:#b08000;">12_345.6789</span>;
];;

<span style="font-weight:bold;">let</span> characters : <span style="color:#0057ae;">char</span> <span style="color:#0057ae;">list</span> = [
    <span style="color:#924c9d;">'a'</span>;
    <span style="color:#924c9d;">' '</span>;
    <span style="color:#924c9d;">'�'</span>;
    <span style="color:#924c9d;">'\n'</span>; <span style="color:#924c9d;">'\r'</span>; <span style="color:#924c9d;">'\t'</span>; <span style="color:#924c9d;">'\b'</span>;    <span style="color:#898887;">(* Control characters. Only these four: not the full C-language range. *)</span>
    <span style="color:#924c9d;">'\000'</span>; <span style="color:#924c9d;">'\128'</span>;            <span style="color:#898887;">(* Decimal character codes. These are always 3 digits. *)</span>
    <span style="color:#924c9d;">'\x02'</span>; <span style="color:#924c9d;">'\xff'</span>; <span style="color:#924c9d;">'\xFF'</span>;    <span style="color:#898887;">(* Hexadecimal character codes. These are always 3 digits. *)</span>
    <span style="color:#924c9d;">'\\'</span>; <span style="color:#924c9d;">'\''</span>; <span style="color:#924c9d;">'\&quot;'</span>; <span style="color:#924c9d;">'&quot;'</span>      <span style="color:#898887;">(* Quote character escapes. *)</span>
];;

<span style="color:#898887;">(* Quotes used to mark constants in parsers should</span>
<span style="color:#898887;">   not be confused with character constant quotes.</span>
<span style="color:#898887;">   </span><span style="color:#898887;font-weight:bold;">&quot;Ticks&quot;</span><span style="color:#898887;"> at the end of identifiers should</span>
<span style="color:#898887;">   not be confused with character constant quotes.  *)</span>
<span style="font-weight:bold;">let</span> basic_identifier =
  <span style="font-weight:bold;">parser</span>
      [&lt; '<span style="color:#924c9d;">'F'</span>; '<span style="color:#924c9d;">'N'</span>; name = s &gt;] -&gt; <span style="font-style:italic;">ID</span> (s, <span style="color:#924c9d;">'f'</span>)
    | [&lt; name = s' &gt;] -&gt; <span style="font-style:italic;">ID</span> (s',<span style="color:#924c9d;">'i'</span>)
;;

<span style="font-weight:bold;">let</span> strings : <span style="color:#0057ae;">string</span> <span style="color:#0057ae;">list</span> = [
    <span style="color:#bf0303;">&quot;&quot;</span>; <span style="color:#898887;">(* Empty string *)</span>
    <span style="color:#bf0303;">&quot;a&quot;</span>; <span style="color:#bf0303;">&quot; &quot;</span>;  <span style="color:#bf0303;">&quot;�&quot;</span>;   <span style="color:#bf0303;">&quot;ab&quot;</span>;
    <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\n</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\r</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\t</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\b</span><span style="color:#bf0303;">B&quot;</span>;  <span style="color:#898887;">(* Control characters. Only these four: not the full C-language range. *)</span>
    <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\000</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\128</span><span style="color:#bf0303;">B&quot;</span>;              <span style="color:#898887;">(* Decimal character codes. These are always 3 digits. *)</span>
    <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\x02</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\xff</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\xFF</span><span style="color:#bf0303;">B&quot;</span>;    <span style="color:#898887;">(* Hexadecimal character codes. These are always 3 digits. *)</span>
    <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\\</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\'</span><span style="color:#bf0303;">B&quot;</span>; <span style="color:#bf0303;">&quot;A'B&quot;</span>;  <span style="color:#bf0303;">&quot;A</span><span style="color:#924c9d;">\&quot;</span><span style="color:#bf0303;">B&quot;</span>;  <span style="color:#898887;">(* Quote character escapes. *)</span>
    <span style="color:#bf0303;">&quot;A multiline</span><span style="color:#924c9d;">\</span>
<span style="color:#bf0303;">    string&quot;</span>;
];

<span style="font-weight:bold;">let</span> camlp4_quotations = [
    <span style="color:#bf0303;">&lt;&lt;A Camlp4 source code quotation.&gt;&gt;</span> ;
    <span style="color:#bf0303;">&lt;:QUOTE&lt;A labelled Camlp4 source code quotation.&gt;&gt;</span> ;
    &lt;:<span style="font-style:italic;">QU</span>�<span style="font-style:italic;">T</span>�&lt;<span style="font-style:italic;">A</span> labelled <span style="font-style:italic;">Camlp4</span> source code quotation. (<span style="font-style:italic;">Latin</span><span style="color:#b08000;">-1</span> identifier.)&gt;&gt; ;
    <span style="color:#bf0303;">&lt;&lt; A quote with an escape: </span><span style="color:#924c9d;">\&gt;&gt;</span><span style="color:#bf0303;"> (end-quote symbol) &gt;&gt;</span> ;
    <span style="color:#bf0303;">&lt;&lt; A quote with an escape: </span><span style="color:#924c9d;">\&lt;&lt;</span><span style="color:#bf0303;"> (plain start quote-symbol) &gt;&gt;</span> ;
    <span style="color:#bf0303;">&lt;&lt; A quote with an escape: \&lt;:Trouv�&lt; (labelled start-quote symbol) &gt;&gt;</span> ;
];;

<span style="color:#898887;">(* end *)</span>
</pre></body></html>
